<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>编程题_实现一个fill函数不能用循环</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
  </style>
</head>

<body>
  <div></div>
</body>
<script>
  "use strict"; {
    // let arr = Array(5).fill("好")
    // console.log(arr)
    let fills = (arr, str, num = 0) => {
      if (arr.length == num) {
        return void 0
      } else {
        arr[num] = str
        num++
        fills(arr, str, num)
      }
    }
    let a = new Array(10)
    fills(a, "我")
    console.log(a)
  };
</script>

</html>